package com.mxf.code.entity;

import com.mysql.jdbc.Driver;
import org.junit.Test;

import java.sql.SQLException;

/**
 * @author : [mxf]
 * @version : [v1.0]
 * @className : RunOrder
 * @description : [描述说明该类的功能]
 * @createTime : [2022/9/15 19:22]
 * @updateUser : [mxf]
 * @updateTime : [2022/9/15 19:22]
 * @updateRemark : [描述说明本次修改内容]
 */
public class RunOrder {

    private A a;

    private static String hh;

    static {
        System.out.println("static");
        hh = "";
    }
    {
        System.out.println("null");
        hh = "hh";
        System.out.println(hh);
    }

    public RunOrder() {

        System.out.println("con");
        this.a = new A();
    }

    /*public RunOrder(String jj) {
        System.out.println("con");
        this.a = new A();
    }*/

    private class A{
        public A() {
            System.out.println("A");
        }
        public void tt(){
            System.out.println("a");
        }
    }

    private static class B{
        public B() {
            System.out.println("B");
        }
        public static void t(){
            System.out.println("b");
        }
    }

    public static void main(String[] args) {
        RunOrder runOrder = new RunOrder();
        RunOrder.B.t();
        runOrder.a.tt();
    }

    @Test
    public void test01(){

        //lable:
        for(int i=0;i<3;i++){
            lable:
            for(int j=0;j<3;j++){
                System.out.println(i);
                if(i == 2) {
                    System.out.println();
                    break lable;
                }

            }
        }

        /*for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                System.out.println(i);
                if(i == 2) {
                    System.out.println();
                    return;
                }

            }
        }*/

        /*for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                System.out.println(i);
                boolean b = false;
                if(j == 1 && i == 1) {
                    b = true;
                    System.out.println();
                    if (b){
                        return;
                    }
                    break;
                }
            }
        }*/

    }

    @Test
    public void stringbuffer(){
        StringBuffer s = new StringBuffer();
        byte a = 127;
        byte b = 127;
        a = (byte) (a + b);
        System.out.println(a);
        //a += b;
        char c = (char)('贡');
    }



    @Test
    public void 逻辑运算符(){
        int i = 1,j = 1,h = 1;
        j = i++;
        j = i;
        System.out.println(j);

        i = 2;
        h = ++i;
        System.out.println(h);

       /* for (int k = 0; k < 10; ++k) {
            System.out.println(k);
        }*/
    }

    @Test
    public void equalsTest(){
        String str1 = "通话";
        String str2 = "重地";
// str1: 1179395 | str2: 1179395
        System.out.println(String.format("str1: %d | str2: %d",str1.hashCode(),str2.hashCode()));
// false
        System.out.println(str1.equals(str2));
    }

    @Test
    public void superTest(){
        F d = new C("d");
        System.out.println(d.getName());
        short s1=1;
        s1 = (short)(s1 + s1);
        System.out.println(++s1);
        int[] i = new int[]{1};
        System.out.println(i.length);
        //System.out.println(i[-1]);
        System.out.println(1 >> 2);

    }


    /*private void tu(){

    }
    public void tu(){

    }*/


    @Test
    public void tryCatch(){
        System.out.println(tcf());
    }

    public static int tcf(){
        try {
            System.out.println(1);
            //int i = 1 / 0;
            return 2;
        }catch (Exception e){
            System.out.println(3);
            return 4;
        }finally {
            System.out.println(5);
            //return 5;
        }
    }

    @Test
    public void newInstance() throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
        Object o = Class.forName("com.mysql.Driver.class").newInstance();
        Driver driver = Driver.class.newInstance();
        Driver driver1 = new Driver();
    }

}



